/**
 * Project Name:src-portal-webapp
 * File Name:XSSRequestWrapper.java
 * Package Name:com.sf.isic.src.wrapper
 * Date:2017年4月10日下午2:46:00
 * Copyright (c) 2017, xutao9@sf-express.com All Rights Reserved.
 *
*/

package com.sf.iguess.wrapper;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

import com.smart.platform.toolkit.XssShieldUtil;

/**
 * ClassName: XSSRequestWrapper <br/>
 * Function: TODO ADD FUNCTION. <br/>
 * Reason: TODO ADD REASON(可选). <br/>
 * date: 2017年4月10日 下午2:46:00 <br/>
 *
 * @author 01135912
 * @version
 * @since JDK 1.7
 */
public class IsicRequestWrapper extends HttpServletRequestWrapper
{
    public IsicRequestWrapper(HttpServletRequest request)
    {
        super(request);
    }
    
    @Override
    public String getParameter(String name)
    {
        // 返回值之前 先进行过滤
        return XssShieldUtil.stripXss(super.getParameter(XssShieldUtil.stripXss(name)));
    }
    
    
    /** 
     * 覆盖getParameterValues方法，将参数名和参数值都做xss过滤 
     */  
    public String[] getParameterValues(String parameter) {  
        String[] values = super.getParameterValues(parameter);  
        if (values==null)  {  
            return null;  
        }  
        int count = values.length;  
        String[] encodedValues = new String[count];  
        for (int i = 0; i < count; i++) {  
            encodedValues[i] =  XssShieldUtil.stripXss(values[i]);
        }  
        return encodedValues;  
    }  
      
}